home *** CD-ROM | disk | FTP | other *** search
/ LOGIC Apps / Logic-APPLE_II_APPS.iso / mac / LOGIC Apple II 5.25" Library - ProDOS / PRO018.dsk / ALARM.CLOCK.bas next >
BASIC Source File  |  2012-02-16  |  6KB  |  130 lines

  1. 100  REM  A L A R M   C L O C K
  2. 110  REM  BY KEITH FALKNER 1986
  3. 120  REM 
  4. 130 D$ =  CHR$(4): REM ctrl-D
  5. 140 KS = 49168: REM KB strobe
  6. 150  DIM F$(36)
  7. 160  PRINT  CHR$(21)
  8. 170  TEXT : HOME : NORMAL : SPEED= 255
  9. 180  READ Z$: IF Z$ < >"*"  THEN  PRINT Z$: GOTO 180
  10. 190  PRINT D$"BLOAD ALARM.OBJ"
  11. 200 TM = 700: REM M/L program
  12. 210  REM 
  13. 220  REM Here is how to fine-tune the clock, in case it is running
  14. 230  REM fast or slow on your particular computer.  The idea here
  15. 240  REM is that we use the 'vertical blanking' signal as a source
  16. 250  REM of 60-cycle pulses. The actual rate varies a little bit
  17. 260  REM from a true 60-cycle signal, so you can adjust the rate
  18. 270  REM at which the clock ticks.  Each second, we count down
  19. 280  REM from 60 to 0, but on the first second of every minute,
  20. 290  REM we count down not from 60, but from 65.  With carefully
  21. 300  REM chosen POKE instructions, which you can add to the program
  22. 310  REM at this point, you can fine-tune the clock so that it keeps
  23. 320  REM perfect time on your computer.  Here are the current POKEs:
  24. 330  REM    POKE 708,60 : rem reset to 60 every second.
  25. 340  REM    POKE 707,60 : rem reset to 60 every tenth second.
  26. 350  REM    POKE 706,65 : rem reset to 65 every minute.
  27. 360  REM    POKE 705,54 : rem reset to 54 every tenth minute.
  28. 370  REM    POKE 704,62 : rem reset to 62 every hour.
  29. 380  REM    POKE 703,57 : rem reset to 65 every tenth hour.
  30. 390  REM The above lines show the POKEs in decreasing order of
  31. 400  REM power.  For example, if you change the POKE to 708 to a
  32. 410  REM number a little bit less, you speed up the clock a lot.
  33. 420  REM If you change the POKE to 704 to a number a little bit
  34. 430  REM more, you slow the clock down just a tiny bit.
  35. 440  PRINT D$"PREFIX": INPUT P$
  36. 450  PRINT D$"OPEN"P$",TDIR"
  37. 460  PRINT D$"READ"P$: INPUT Z$,Z$,Z$
  38. 470  INPUT Z$: IF Z$ = "" GOTO 490
  39. 480 F = F +1:F$(F) =  MID$ (Z$,2,15): IF F <36 GOTO 470
  40. 490  PRINT D$"CLOSE"
  41. 500  PRINT "Press the space-bar to continue: ";
  42. 510  POKE KS,0: GET K$
  43. 520  VTAB 23: PRINT : HOME 
  44. 530  IF K$ =  CHR$(3)  OR K$ =  CHR$(27)  THEN  PRINT D$"-STARTUP"
  45. 540 FP = 0
  46. 550  INVERSE : VTAB 22: PRINT "SELECT WITH ARROWS, THEN PRESS <RETURN>"
  47. 560  NORMAL : PRINT "  YOU ARE CHOOSING THE PROGRAM THAT"
  48. 570  PRINT "  WILL BE RUN WHEN THE ALARM GOES OFF.";
  49. 580  VTAB 1: HTAB 1: INVERSE : PRINT "PROGRAMS ON DISK "P$; TAB( 39)"": NORMAL 
  50. 590  DEF  FN FL(I) = I +2 -18 *(I >18)
  51. 600  DEF  FN FC(I) = 3 +22 *(I >18)
  52. 610  FOR I = 1 TO F: VTAB  FN FL(I): HTAB  FN FC(I): PRINT F$(I): NEXT 
  53. 620 FC = 3
  54. 630  IF FC <1  THEN FC = F
  55. 640  IF FC >F  THEN FC = 1
  56. 650  INVERSE : VTAB  FN FL(FC): HTAB  FN FC(FC): PRINT F$(FC): NORMAL 
  57. 660  VTAB 22: HTAB 40: POKE KS,0: GET K$
  58. 670  NORMAL : VTAB  FN FL(FC): HTAB  FN FC(FC): PRINT F$(FC)
  59. 680 K =  ASC(K$ +" ")
  60. 690 FC = FC +(K = 32) +(K = 10) -(K = 11) +20 *(K = 21) -20 *(K = 8) + VAL(K$)
  61. 700  IF K < >13 GOTO 630
  62. 710 CM$ = "- " +F$(FC)
  63. 720  HOME : VTAB 6: PRINT "Enter the current time as    HHMMSS."
  64. 730  PRINT "(about 20 seconds from now): ";
  65. 740 ZL = 235959: GOSUB 1010
  66. 750 TI$ =  RIGHT$( STR$(1000000 +Z),6)
  67. 760  PRINT : PRINT : PRINT "And the time for alarm as    HHMMSS."
  68. 770  PRINT  SPC( 28)":";
  69. 780 ZL = 235959: GOSUB 1010
  70. 790 TA$ =  RIGHT$( STR$(1000000 +Z),6)
  71. 800  HOME : VTAB 6: PRINT "    Current time is ";:Z$ = TI$: GOSUB 1230
  72. 810  PRINT : PRINT : PRINT "    Alarm's set for ";:Z$ = TA$: GOSUB 1230
  73. 820  PRINT : PRINT : PRINT "   This command will be issued:"
  74. 830  PRINT "   "CM$
  75. 840  VTAB 22: PRINT "Press space bar at exactly ";
  76. 850 Z$ = TI$: GOSUB 1230: PRINT ". ";
  77. 860  POKE KS,0: GET K$
  78. 870  VTAB 21: PRINT : CALL  -958
  79. 880  REM -> current on screen
  80. 890  VTAB 6: HTAB 21
  81. 900  CALL TM
  82. 910  VTAB 17: PRINT 
  83. 920  IF TI$ = TA$ GOTO 950
  84. 930  PRINT "   Alarm cancelled from keyboard."
  85. 940  POKE KS,0: GOTO 1390
  86. 950  PRINT "   Alarm time has been reached."
  87. 960  PRINT D$CM$
  88. 970  GOTO 1390
  89. 980  REM 
  90. 990  REM subroutine to get
  91. 1000  REM a number from keys
  92. 1010 Z = 0:ZW = 0: POKE KS,0
  93. 1020  GET K$: IF Z  AND (K$ =  CHR$(13))  THEN  PRINT : RETURN 
  94. 1030  IF K$ =  CHR$(127)  OR K$ =  CHR$(8) GOTO 1070
  95. 1040  IF K$ <"0"  OR K$ >"9" GOTO 1020
  96. 1050 ZT = Z *10 + VAL(K$): IF ZW = 6  OR ZT >ZL GOTO 1020
  97. 1060  PRINT K$;:Z = ZT:ZW = ZW +1: GOTO 1020
  98. 1070  IF ZW = 0 GOTO 1020
  99. 1080  PRINT  CHR$(8)" " CHR$(8);
  100. 1090 ZW = ZW -1:Z =  INT(Z/10): GOTO 1020
  101. 1100  REM subrroutine to get
  102. 1110  REM a string from keys
  103. 1120 Z$ = "": POKE KS,0
  104. 1130  GET K$: IF K$ =  CHR$(13)  THEN  PRINT : RETURN 
  105. 1140  IF K$ =  CHR$(127)  OR K$ =  CHR$(8) GOTO 1180
  106. 1150  IF K$ <" "  OR  LEN(Z$) = ZL GOTO 1130
  107. 1160  IF K$ =  >"a"  AND K$ < = "z"  THEN K$ =  CHR$( ASC(K$) -32)
  108. 1170  PRINT K$;:Z$ = Z$ +K$: GOTO 1130
  109. 1180  IF Z$ = "" GOTO 1130
  110. 1190  PRINT  CHR$(8)" " CHR$(8);
  111. 1200 Z$ =  MID$ (Z$,1, LEN(Z$) -1): GOTO 1130
  112. 1210  REM subroutine to print
  113. 1220  REM time as HH:MM:SS
  114. 1230  PRINT  LEFT$(Z$,2)":" MID$ (Z$,3,2)":" RIGHT$(Z$,2);: RETURN 
  115. 1240  DATA This program is a real-time clock.,
  116. 1250  DATA There are three things you should do --,
  117. 1260  DATA 1. Enter the time as HHMMSS.
  118. 1270  DATA "   e.g.  10:30 PM is 223000.",
  119. 1280  DATA 2. Enter the alarm-time as HHMMSS.,
  120. 1290  DATA 3. Select a program from those on
  121. 1300  DATA "   this disk, and it will be run"
  122. 1310  DATA "   when the alarm-time is reached.",
  123. 1320  DATA To cancel the alarm at any time before
  124. 1330  DATA the alarm 'goes off' just press any
  125. 1340  DATA key on the keyboard.,
  126. 1350  DATA "If you copy this program to another"
  127. 1360  DATA "disk, be sure to copy the machine-"
  128. 1370  DATA "language program ALARM.OBJ there too."
  129. 1380  DATA *: REM end of rules
  130. 1390  END